{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this notebook we show basic interactive use of Gobnilp with discrete data."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The first thing we do is to import the Gobnilp class from the gobnilp Python module and create a Gobnilp object which here we choose to call `m`. Practically all interactive sessions start with these two steps."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Academic license - for non-commercial use only\n"
     ]
    }
   ],
   "source": [
    "from gobnilp import Gobnilp\n",
    "m = Gobnilp()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that Gurobi (not Gobnilp) here prints out the type of Gurobi licence installed.\n",
    "Next we use the method `use_discrete_data` which reads in discrete data and learns a Bayesian network from it.\n",
    "We're using default parameters so BDeu scoring (with an *effective sample size* of 1) will be used. The dataset we use is `discrete.dat` which comes with Gobnilp. This dataset is called 'learning.test' in the bnlearn R package.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24028.09477835351\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "D<-A,C -3555.0144442365527\n",
      "E<-B,F -4310.3049564706525\n",
      "F<- -3470.18794067853\n",
      "**********\n",
      "[A][B|A][C][D|A:C][E|F:B][F]\n",
      "CPDAG:\n",
      "Vertices: ['A', 'B', 'C', 'D', 'E', 'F']\n",
      "A-B\n",
      "A->D\n",
      "B->E\n",
      "C->D\n",
      "F->E\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0c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wAE6csL8/eBCOHIEvvlDgijMKXXHnhx9gypTz35eeDj17BmaL2YUmoW3caG8ijih0xZ3Bg39ahWbx+20l+vbbV/e5N2+2o8kZGee/PyPDjiqLOKKerrjz6KO2Xeubb+Drr63Xun+/7Zvt29cerF2p5GRrWRQsaA/MKlaEqlXh+uuhbt3A/TuI5JDPf4mXcXFxcf41a9YEsRwRbEfDiRNQtOgvPlS5cmUOHjxIVFTUj+/r3r0748aNO/83+v22qo2Jye1qRX7B5/Ot9fv9cRf6mFa64j15814wcLPMnTuX2y93D5nPp8AVT1JPV0QkiBS6IiJBpNCVkNO2bVuKFi3649vrr7/uuiSRbFNPV0JOcnLy5Xu6Ih6lla6ISBApdEVEgkihKyEnMTGR2NjYH9/atWvnuiSRbFNPV0LKTq/ePiGSTVrpiogEkUJXRCSIFLoiIkGk0BURCSKFrohIECl0RUSCSKErIhJECl0RkSBS6IqIBJFCV0QkiBS6IiJBpNAVEQkiha6ISBApdEVEgsjn9/sv/kGf7xCwK3jliIiEhUp+v7/UhT5wydAVEZHAUntBRCSIFLoiIkGk0BURCSKFrohIECl0RUSC6P8B1JLij/osaiAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m.use_discrete_data('discrete.dat')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It is worth going through the output step by step.\n",
    "1. First we get the 'score' (in this case the BDeu score) of the learned Bayesian network. Since this was learned using default parameters this network has the best possible score of all networks **with the default limit on the number of parents a node can have** which is 3.\n",
    "2. Next we get a textual representation of the learned BN. In each line we get the parents of a node together with the *local score* for this child-parents combination. The score of the network is just the sum of these local scores.\n",
    "3. After this we get another textual representation of the network. This is the representation used by [bnlearn](http://bnlearn.com)\n",
    "4. Then we get a textual representation of the *completed partially directed acyclic graph (CPDAG)* for the learned BN. This represents the Markov equivalence class of all BNs having the same conditional independence relations as the learned BN.\n",
    "5. Finally we get a visual representation of the learned BN. In this Jupyter notebook the graph automatically gets embedded in the notebook. When running Gobnilp as a script or from a normal Python interpreter the network will appear in a window. Red arrows have the displayed orientation in every BN in the learned BN's Markov equivalence class. Black arrows are 'reversible'. In this case if we were to reverse the arrow from A to B then we would not create a cycle nor would we create or destroy any 'immoralities' (pairs of unmarried parents). So this arrow can be reversed to render a Markov equivalent BN."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is all very well but perhaps we could find a higher scoring network is we did not have a parent set size limit of 3. So let's run again without this restriction and see what we get. The easiest option is just to create a new object (with the same name) and set the `palim` argument to None. (When using `palim` as an optional argument when running Gobnilp as a script it is necessary to set it to a number so that it is parsed correctly. But here `None` is OK and more intutitive. Setting it to, say, 99 would have the same effect.) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24028.09477835351\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "D<-A,C -3555.0144442365527\n",
      "E<-B,F -4310.3049564706525\n",
      "F<- -3470.18794067853\n",
      "**********\n",
      "[A][B|A][C][D|A:C][E|F:B][F]\n",
      "CPDAG:\n",
      "Vertices: ['A', 'B', 'C', 'D', 'E', 'F']\n",
      "A-B\n",
      "A->D\n",
      "B->E\n",
      "C->D\n",
      "F->E\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAbiUlEQVR4nO3de5zOZf7H8ddtBoOR8zFiaS3JeXYGEZ2UGOucpOKn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+Drr63Xun+/7Zvt29cerF2p5GRrWRQsaA/MKlaEqlXh+uuhbt3A/TuI5JDPf4mXcXFxcf41a9YEsRwRbEfDiRNQtOgvPlS5cmUOHjxIVFTUj+/r3r0748aNO/83+v22qo2Jye1qRX7B5/Ot9fv9cRf6mFa64j15814wcLPMnTuX2y93D5nPp8AVT1JPV0QkiBS6IiJBpNCVkNO2bVuKFi3649vrr7/uuiSRbFNPV0JOcnLy5Xu6Ih6lla6ISBApdEVEgkihKyEnMTGR2NjYH9/atWvnuiSRbFNPV0LKTq/ePiGSTVrpiogEkUJXRCSIFLoiIkGk0BURCSKFrohIECl0RUSCSKErIhJECl0RkSBS6IqIBJFCV0QkiBS6IiJBpNAVEQkiha6ISBApdEVEgsjn9/sv/kGf7xCwK3jliIiEhUp+v7/UhT5wydAVEZHAUntBRCSIFLoiIkGk0BURCSKFrohIECl0RUSC6P8B1JLij/osaiAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m = Gobnilp()\n",
    "m.use_discrete_data('discrete.dat',palim=None)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "OK, so this **is** really the optimal BN! Just to check that the parent set size limit is working, let's do this again but set the limit to 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24933.777022652117\n",
      "**********\n",
      "A<-D -4376.280191070102\n",
      "D<-C -5485.591606147809\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "E<-B -4854.487880793349\n",
      "F<-E -3026.9672848237205\n",
      "**********\n",
      "[A|D][D|C][B|A][C][E|B][F|E]\n",
      "CPDAG:\n",
      "Vertices: ['A', 'D', 'B', 'C', 'E', 'F']\n",
      "A-B\n",
      "D-A\n",
      "B-E\n",
      "C-D\n",
      "E-F\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAMPUlEQVR4nO3dT2hcVQOG8ffO5CYTZ0oSkzS1lXTEVRUV7NBGadBFLUSNJFFb/4RaCWixkZEUrNoKpeqiIq5cCC4kAQt1NtNGkG7cNKBgCilIlICQqDWmX+skmWmmcTq536qlhaa9k/qd4/F7fjAL527e1cPh9DrxgiAQAMCMiO0BAPD/hOgCgEFEFwAMIroAYBDRBQCDqm70sKmpKUgmk4amAMC/w6lTp84FQdB8vWc3jG4ymdTo6Oj/ZhUA/Et5nje13DOuFwDAIKILAAYRXQAwiOgCgEFEFwAMIroAYBDRBQCDiC4AGER0AcAgogsABhFdADCI6AKAQUQXAAwiunDOkSNHlEqllEgkdMcdd6ijo0MjIyO2ZwGhEF045eOPP9Ybb7yhd955RzMzM/rll1/02muv6dixY7anAaF4N/oT7KlUKuD3dPFPMTc3p3Xr1unzzz/Xs88+a3sOsCzP804FQZC63jNOunDGt99+q4sXL6q7u9v2FGDFiC6ccf78eTU1Namq6oZ/8AT4RyO6cEZjY6POnTunS5cu2Z4CrBjRhTMeeughxWIxZbNZ21OAFSO6cEZdXZ0OHTqkPXv2KJvNamFhQaVSSV9//bXefPNN2/OAULgcg1MGBgbU0tKi999/Xy+++KJWrVqljRs3av/+/banAaHwyhgA/M14ZQwA/iGILgAYRHQBwCCiCydlMhkVi0XbM4CKEV04KZ1OK5fL2Z4BVIzoAoBBRBcADCK6AGAQ0QUAg4guABhEdAHAIKILAAYRXQAwiJ92hDPm5+eVz+clSeVyWdPT0wqCQLFYTI2NjZbXAeEQXThjy5Yt+umnn+T7vhYWFtTe3q6lpSUtL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ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m = Gobnilp()\n",
    "m.use_discrete_data('discrete.dat',palim=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "OK, we get a lower scoring network. This one happens to be a chain with all arrows reversible."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
